#include "ControlFrame.h"

ControlFrame::ControlFrame()
    : wxFrame( NULL, -1,  wxT("eMachine"), wxPoint(50,50), wxSize(CONTROL_FRAME_WIDTH,CONTROL_FRAME_HEIGHT)),
    m_cmd_panel(NULL), m_model_panel(NULL),m_model(NULL), m_model_draw(NULL)
{

}

bool ControlFrame::setup()
{
    CreateStatusBar(2);
    SetStatusText(_T("Welcome to eMachine System!"));

    wxBoxSizer* p_sizer = new wxBoxSizer(wxHORIZONTAL);
    SetSizer(p_sizer);

    m_model_panel = new ModelPanel(this);
    if( !m_model_panel){
        goto fail;
    }
    m_model_panel->setModelDraw( m_model_draw );
    m_model_panel->setup();

    m_cmd_panel = new CmdPanel(this);
    if( !m_cmd_panel ){
        goto fail;
    }
    m_cmd_panel->setModelPanel( m_model_panel );
    m_cmd_panel->setup();

    p_sizer->Add(m_model_panel,1,wxEXPAND);
    p_sizer->Add(m_cmd_panel, 0,wxEXPAND);



/* 
    wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);

    frame->SetBackgroundColour(wxColor(0,0,0));

    drawPane = new BasicDrawPane( (wxFrame*) frame );
    sizer->Add(drawPane, 1, wxEXPAND);

    frame->SetSizer(sizer);
    frame->SetAutoLayout(true);

    frame->Show();

*/

    Show();

    return true;
fail:
    if( m_model_panel ){
        m_model_panel->teardown();
        delete m_model_panel;
    }

    if( m_cmd_panel ){
        m_cmd_panel->teardown();
        delete m_cmd_panel;
    }
    return false;
}


bool ControlFrame::teardown()
{

    return false;
}

void ControlFrame::setModel(Model* model)
{
    m_model = model;
}

Model* ControlFrame::getModel()
{
    return m_model;
}

void ControlFrame::setModelDraw(ModelDraw* mdraw)
{
    m_model_draw = mdraw;
}

ModelDraw* ControlFrame::getModelDraw()
{
    return m_model_draw;
}